package com.leoman.adsindex.dao;

import com.leoman.adsindex.entity.AdsIndex;
import com.leoman.banner.entity.Banner;
import com.leoman.common.dao.IBaseJpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by Administrator on 2016/6/12.
 */
public interface AdsIndexDao extends IBaseJpaRepository<AdsIndex> {

    @Query("select a from AdsIndex a where a.position = 1")
    public AdsIndex iFindOne();

    @Query("select a from AdsIndex a where a.position = ?1 and a.workId = ?2")
    public List<AdsIndex> findByTypeAndWorkId(Integer type, Long workId);

    @Query("select a from AdsIndex a where a.position = ?1 and a.categoryId = ?2")
    public List<AdsIndex> findByTypeAndCategoryId(Integer type, Long categoryId);

    @Query("select a from AdsIndex a where a.position = ?1 and a.categoryId = ?2 and a.workId = ?3")
    public List<AdsIndex> findMusicAndGame(Integer type, Long categoryId, Long workId);
}
